
package com.jjyu.controller;

import com.jjyu.entity.Result;
import com.jjyu.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/coupons")
public class CouponController {

    @Autowired
    private CouponService couponService;

    @PostMapping("/expired")
    public Result deleteExpiredCoupons(@RequestBody String userId) {
        int deletedCount = couponService.deleteExpiredCoupons(userId);
        if (deletedCount > 0) {
            return Result.success("已删除" + deletedCount + "张过期优惠券");
        } else {
            return Result.error("没有过期的优惠券可删除");
        }
    }
}